import { Sequelize } from "sequelize";
import dbDevConf from "./db.local";

// 从环境变量中读取数据库配置
const { MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_ADDRESS = '', MYSQL_PROT, MYSQL_NAME } : {
  MYSQL_USERNAME: string,
  MYSQL_PASSWORD: string,
  MYSQL_ADDRESS: string,
  MYSQL_PROT: number,
  MYSQL_NAME: string,
} = dbDevConf;


const sequelize = new Sequelize(MYSQL_NAME, MYSQL_USERNAME, MYSQL_PASSWORD, {
  host: MYSQL_ADDRESS,
  port: MYSQL_PROT,
  dialect: 'mysql' /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */,
});

// 导出初始化方法和模型
export  {
  sequelize,
};
